Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cassandra] Add: schema browser support & explicit protocol version #1482

Merged
merged 4 commits into from
Jan 3, 2017
Merged

[Cassandra] Add: schema browser support & explicit protocol version #1482

merged 4 commits into from
Jan 3, 2017

Conversation

yershalom
Copy link
Contributor

…o 3 (Also working with cassandra version 2.1 and above)

…o 3 (Also working with cassandra version 2.1 and above)
schema[table_name] = {'name': table_name, 'columns': []}
CN_query = """
SELECT column_name FROM system.schema_columns where keyspace_name ='{}' and columnfamily_name ='{}';
""".format(self.configuration['keyspace'], table_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not run: SELECT columnfamily_name, column_name FROM system.schema_columns where keyspace_name ='{}' and split them to column families in the code? This way you need to run only a single query instead of N queries.

@@ -54,22 +54,36 @@ def type(cls):
return "Cassandra"

def _get_tables(self, schema):
query = """
CF_query = """
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf_query

@@ -14,7 +14,7 @@
enabled = False


class Cassandra(BaseQueryRunner):
class Cassandra(BaseSQLQueryRunner):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when I use BaseQueryRunner i'm getting empty list [] for get_tables

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, because you need to implement get_schema instead (get_tables is a method BaseSQLQueryRunner uses for get_schema).

@arikfr arikfr changed the title Added get tables query for cassandra and expilicit protocol version t… [Cassandra] Add: schema browser support & explicit protocol version Jan 3, 2017
@arikfr
Copy link
Member

arikfr commented Jan 3, 2017

What's the need for protocol version?

@yershalom
Copy link
Contributor Author

I added this because I want to avoid from the warning log. If you are using Cassandra 2.1 so it throws a warning about downgrading the protocol version.
screen shot 2017-01-03 at 10 26 11 am

This is from the cassandra driver code - https://github.com/datastax/python-driver/blob/master/cassandra/cluster.py#L1118

@arikfr
Copy link
Member

arikfr commented Jan 3, 2017

OK, if anyone will have a problem with this, we will add this as a parameter.

@arikfr
Copy link
Member

arikfr commented Jan 3, 2017

Btw, Scylla supports this too, right?

@yershalom
Copy link
Contributor Author

Yes.

@arikfr arikfr merged commit 2df0979 into getredash:master Jan 3, 2017
@arikfr
Copy link
Member

arikfr commented Jan 3, 2017

Thanks ! :)

dairyo pushed a commit to KiiCorp/redash that referenced this pull request Mar 1, 2019
[Cassandra] Add: schema browser support & explicit protocol version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants